package com.hq.fxh.No6UerSpace.Adapter;

import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hq.fxh.R;
import com.hq.fxh.Utils.AppConstant;
import com.hq.fxh.Utils.DensityUtils;
import com.hq.fxh.Utils.GlideUtils;
import com.hq.fxh.Utils.SystemUtils;
import com.hq.fxh.Utils.Tool;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/20
 * @Email xlwenhao1858@sina.com
 */


public class Radapter_UserSpace_CanPin extends RecyclerView.Adapter<Radapter_UserSpace_CanPin.CanPinViewHolder> {


    Context context;


    @Override
    public CanPinViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();

        CanPinViewHolder canPinViewHolder = new CanPinViewHolder(View.inflate(context, R.layout.item_myplate_canpin, null));


        return canPinViewHolder;
    }

    @Override
    public void onBindViewHolder(CanPinViewHolder holder, int position) {
        GlideUtils.loadImageView(context, AppConstant.imageUrl, holder.imageCanPinPic);
        if(position%2==1){
            Tool.setStringToText(holder.tvItemCanPinName,"你想要的东西都在这里 来看看如何想要的东西都在这里 来看看如何想要的东西都在这里");

        }else {
            Tool.setStringToText(holder.tvItemCanPinName,"你想要的 ");

        }

    }

    @Override
    public int getItemViewType(int position) {
        if (position % 2 == 0) {

            return 1;
        } else {
            return 0;
        }
    }

    @Override
    public int getItemCount() {
        return 10;
    }


    class CanPinViewHolder extends RecyclerView.ViewHolder {
        protected ImageView imageCanPinPic;
        protected TextView tvItemCanPinName;
        protected TextView tvItemCanPinJiaGe;
        protected LinearLayout layoutItemContent;

        public CanPinViewHolder(View itemView) {
            super(itemView);
            initView(itemView);
        }


        private void initView(View rootView) {
            imageCanPinPic = (ImageView) rootView.findViewById(R.id.image_CanPin_Pic);
            tvItemCanPinName = (TextView) rootView.findViewById(R.id.tv_Item_CanPin_Name);
            tvItemCanPinJiaGe = (TextView) rootView.findViewById(R.id.tv_Item_CanPin_JiaGe);
            layoutItemContent = (LinearLayout) rootView.findViewById(R.id.layout_Item_Content);

          float windowWidth = (float) SystemUtils.getWindowWidth((Activity) context);
            int i = DensityUtils.dip2px(context, 40);
            int viewWidth = (int) (windowWidth - i);

           Tool.setViewWH(imageCanPinPic,0, (viewWidth / 2));
        }
    }


}
